Running Pog Scripts


Getting a Pog script running in the game can be accomplished in several ways:

 

Modifying the Scripts.ini File

The scripts.ini file is located in the resource.zip. Whenever the game transitions from one major state to another (such as exiting from the player base into space) the scripts in the appropriate section of the scripts.ini are executed. Here's the default scripts.ini file:

[Game]
; Run these scripts atomically when the player starts a new game
enter[]=iStartSystem.StartupNewGame
enter[]=iFactionScript.Initialise

[Session]
; Run these scripts atomically when the player starts a new game
; or loads a saved game.
enter[]=iCargoScript.Initialise
enter[]=iStartSystem.StartupSession

; Run these scripts atomically when the player ends a game
exit[]

[Base]
; Run these scripts atomically when the player enters the base.
;enter[]=

; Run these scripts atomically when the player leaves the base.
;exit[]=

[Space]

; Run these scripts atomically when the player enters space.
enter[]=iStartSystem.StartupSpace
enter[]=iUtilities.AllowMissionSkipping
enter[]=iMissionTracker.Initialise
enter[]=iMusic.Initialise

; Run these scripts after the act scripts but before play begins
final_setup[]=iStartSystem.FinalSetup
final_setup[]=iBackToBase.Initialise

; Run these scripts atomically when the player leaves space.
exit[]=iStartSystem.ShutdownSpace
exit[]=iMusic.Terminate
exit[]=iBackToBase.Terminate

[System]
; Run these scripts atomically when the player enters a new system
enter[]=iStartSystem.StartupSystem
enter[]=iTrafficCreation.DisableTrafficReport
enter[]=iRangeCheck.DisableRangeReport
enter[]=iStation.DisableStationReactiveReport

; Run these scripts atomically when the player leaves a new system
exit[]=iStartSystem.ShutdownSystem

Only non-task functions with no parameters can be called using the scripts.ini file. The function used must be exported via the provides command in the script, and is specified without the parentheses, e.g. enter[]=iExample.MyFunction

See the INI File section for details of INI file creation and structure.

To modify the scripts.ini file it is best to extract it from the game's resource.zip file. You will need to create a resource folder in the game installation folder, and place the scripts.ini file in there. See File System for more information about zip files and the game's file system.

The advantage in using the scripts.ini file is that all the standard game scripts, such as space traffic creation, etc. will run alongside your script.

The disadvantage is that only one copy of the scripts.ini can be active at one time, so if two or more Mods that use the scripts.ini to run their scripts are active simultaneously, there will be a conflict and only one mod will work.

 

Scenario Mod Function

Versions of I-War 2 from F14.6 or later allow for user scenarios to be created. These user scenarios are accessed from the Extras screen.

Only one scenario can be active at any one time. The advantage to running a script via the scenario feature, is that it provides an easy user-friendly way to activate your script. The disadvantage is that none of the default game scripts (such as traffic creation) will run so if you want traffic, etc. you'll have to call the setup functions manually.

See Mod Creation and Distribution for more details.

 

Using an Existing Game Script

Another way of running your script is to piggy back your script on an existing script, by inserting the function call that starts your script into another one. However this requires you having the source code for the script you want to put your script initialisation call into.

 

Using the Script Test feature

Your can easily test a script by inserting a couple of entries into the game's flux.ini file. The advantage to this method is that it's very easy to get your script up and running. The disadvantage is that the script will replace the game's story script, and it requires you to manually edit the flux.ini file to get it working (which makes it not very useful if you intend to distribute your script).

To get a script running add these sections into the flux.ini file (Make a backup of the flux.ini first).

[Test]
package=iExample.MyScript
ship=ini:/sims/ships/player/comsec_prefitted

Replace the package entry with the call to your script function, and the ship entry with a prefitted player ship.

Important: The standard player ships will not work - you must use a prefitted ship with the necessary player systems already included.

Note: If your script uses states to restart itself automatically, then you may find your script runs twice if you enter then exit the player base. There are ways to get around this, e.g. by creating a global variable when your script first runs, then check for it in your script.